<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%String path = request.getContextPath();String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<%--系统同步日志管理 --%>
	<title>${title}</title>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
	<link rel="stylesheet" type="text/css" href="<c:url value='/resource/css/common.css'/>"/>
	<script type="text/javascript" src="<c:url value='/resource/js/jquery-1.7.2.min.js'/>"></script>
	<script type="text/javascript" src="<c:url value='/resource/js/jquery.form.js'/>"></script>
	<script type="text/javascript" src="<c:url value='/resource/js/JTimer.js'/>"></script>
	<script type="text/javascript" src="<c:url value='/resource/artdialog/artdialog.js?skin=${sys_theme}'/>"></script>
	<script type="text/javascript" src="<c:url value='/resource/artdialog/iframetools.js'/>"></script>
	<script type="text/javascript" src="<c:url value='/resource/js/My97DatePicker/WdatePicker.js'/>"></script>
	<script type="text/javascript">
		//分页
		function _goto(pageIndex){
			var url = "<c:url value='/sync/query/@.html'/>".replace("@",pageIndex);
			$("#sync_log_form").attr("action",url);
			$("#sync_log_form").submit();
		}
		
		$(function(){
			//界面初始化
			$("#tbl_container").css({"height":$(window).height()-85,"width":$(window).width()});
			$("#div_nav").css({"width":$(window).width()});
			$("#tbl_datalist tr:even td").css({"background-color":"#f2f7fd"});
			if($(window).width()<860){
				$("#tbl_datalist tr:gt(0)").each(function(index,obj){
					$(this).find(".name1").text(function(){
						var _tmp = $(this).text();
						return _tmp.length>=20?_tmp.substring(0,20)+"...":_tmp;
					});
				});
			}else{
				$("#tbl_datalist tr:gt(0)").each(function(index,obj){
					$(this).find(".name1").text(function(){
						var _tmp = $(this).text();
						return _tmp.length>=20?_tmp.substring(0,20)+"...":_tmp;
					});
				});
			}
			$("#btn_log_search").click(function(){
				var bool =false;
				var synctime1 = $("#synctime1").val().replace(/(^\s*)|(\s*$)/g,'');
				var synctime2 = $("#synctime2").val().replace(/(^\s*)|(\s*$)/g,'');
				if(("" != synctime1 && "" == synctime2) || (""!=synctime2 && ""==synctime1)){
					art.dialog.tips("操作时间必须是一个时间段！！请重新选择！");
					return false;
				}else{
					var url = "<c:url value='/sync/query/1.html'/>";
					$("#sync_log_form").attr("action",url);
					$("#sync_log_form").submit();
				}
			});
		});
		
		function resync(appid,tableName,dbId){
			
		
			var url = "<%= request.getContextPath()%>" + "/sync/sync/"+appid+"/"+tableName+"/"+dbId+".json";
			top.maskPage();
			$.ajax({
				url:url,
				dataType:"json",
				success:function(data){
				top.unmaskPage();
					switch(data.data.status){
						case 1:
							art.dialog.tips(data.data.body,3);
							window.setTimeout(function(){
								window.parent.frames["ifrm_data"].location.reload();
								art.dialog.close();
							},3000);
						break;
						case 0:
							art.dialog.tips(data.data.body,3);
							window.setTimeout(function(){
								window.parent.frames["ifrm_data"].location.reload();
								art.dialog.close();
							},3000);
							break;
					}
				},
				error: function () {
					top.unmaskPage();
				   art.dialog.alert("同步失败！");
				}
			});
		}
	</script>
</head>
<body style="margin:0 auto;">
	<div>
		<div style="height:45px;line-height:45px;">
			<form id="sync_log_form" class="searchForm" action="<c:url value='/sync/query/1.html'/>">
	    		<ul class="list_title form_ul" style="width:100%;">
					<li style="width:55px;text-align:right;">应用系统</li>
	    			<li class="l3" style="width:105px;" ><input type="text" id="appname" name="appname" onblur="this.value=this.value.replace(/[^\w\b\u4e00-\u9fa5]/g,'');" style="width:100px;" value="${appname }" maxlength="15"/></li>
					<li style="width:42px;text-align:right;">同步表</li>
					<li class="l3" style="width:102px;" ><input type="text" id="userid" name="synctab" style="width:100px;" value="${synctab}" maxlength="15" onblur="this.value=this.value.replace(/[^\w\b\u4e00-\u9fa5]/g,'');" ondblclick="this.value = '';"/></li>
					<li style="width:30px;text-align:right;">结果</li>
					<li class="l3" style="width:65px;">
						<select name="result" style="height:22px;line-height:22px;margin-top:2px;padding:0px;padding:2px 0 2px 0;">
							<option value="">全部</option>
							<option value="1" ${'1' eq result ? 'selected=selected':''}>成功</option>
							<option value="0" ${'0' eq result ? 'selected=selected':''}>失败</option>
						</select>
					</li>
					<li style="width:62px;text-align:right;">同步时间</li>
					<li style="width:120px;" class="l3">
						<input type="text" id="synctime1" name="synctime1" style="width:120px;" readonly="readonly" class="Wdate" value="${synctime1}" onclick="WdatePicker();"/> 
					</li>
					<li style="width:30px;">至</li>
					<li style="width:120px;" class="l3">
						<input type="text" id="synctime2" name="synctime2" style="width:120px;" readonly="readonly" class="Wdate" value="${synctime2}" onclick="WdatePicker();"/> 
					</li>
					<li >
						<input type="button" value="查询" id="btn_log_search" class="mac_btn2" style="margin-left: 2px;"/>
					</li>
				</ul>
	    	</form>
	    </div>
	    <div id="tbl_container">
			<table id="tbl_datalist" class="tbl_datalist" cellpadding="0" cellspacing="0">
	   			<thead>
		   			<tr>
		   				<th class="txt_center" width="35" style="text-align: center;">序号</th>
		   				<th>应用系统</th>
		   				<th>同步表名</th>
		   				<th>同步时间</th>
		   				<th class="txt_center">同步结果</th>
		   				<th>备注信息</th>
		   				<th class="text_center" style="text-align:center;">操作</th>
		   			</tr>
	   			</thead>
	   			<c:forEach var="data" items="${page.list}" varStatus="vs">
	   			<tr>
	   				<td class="txt_center" width="35" style="text-align: center;">${((page.pageIndex-1)*page.pageSize)+vs.count}</td>
		   			<td>${data.appname}</td>
		   			<td>${data.synctab}</td>
	   				<td>${data.synctime}</td>
		   			<td style="text-align:center;">${'1' eq data.syncres ? '成功':'失败'}</td>
		   			<td class="name1" title="${data.remark}">${data.remark}</td>
		   			<td style="padding-right:5px;text-align:center;">
		   				<c:if test="${data.syncres ==1}">
		   					<font style="color:#ccc;">
		   						<img title="同步" alt="同步" src="<c:url value='/resource/images/resync.png'/>" class="disabled"></img>
		   					</font>
		   				</c:if>
		   				<c:if test="${data.syncres ==0}">
		   					<img title="同步" alt="同步" style="cursor: pointer;" src="<c:url value='/resource/images/resync.png'/>" onclick="resync('${data.appid}','${data.synctab}','${data.dbid}')"></img>
		   					<!-- <a href="<c:url value='/sync/rsync/${data.appid}/${dbid}'/>">重新同步</a> -->
		   				</c:if>
		   			</td>
	   			</tr>
	   			</c:forEach>
	   		</table>
	   	</div>
	   	<div style="clear:both;"></div>
	   	<div id="div_nav" style="height:30px;line-height:30px;">
			<table style="width:100%;">
	   			<tr>
	   				<td style="text-align:center;">
						<table id="nav_tbl">
							<tr>
								<td>
									<c:if test="${page.previousPage}"><a onclick="_goto(${page.pageIndex-1});">上一页 </a></c:if>
									<c:if test="${not page.previousPage}">上一页</c:if>
								</td>
						 		<c:forEach var="nav" items="${page.navigatePageNumbers}" varStatus="vs">
						 		<td><a onclick="_goto(${page.navigatePageNumbers[vs.index]});" <c:if test="${page.pageIndex == page.navigatePageNumbers[vs.index]}">style="border:1px solid #1f2b62;font-weight:bold;"</c:if>>${page.navigatePageNumbers[vs.index]}</a></td>
						 		</c:forEach>
								<td>
							 		<c:if test="${not page.nextPage}">下一页</c:if>
							 		<c:if test="${page.nextPage}"><a onclick="_goto(${page.pageIndex+1});">下一页 </a></c:if>
								</td>
								<td><input id="txt_page_index" type="text" value="${page.pageIndex}" size="5" maxlength="5" onblur="_goto(eval('this.value>${page.totalPage}?${page.totalPage}:this.value<1?1:this.value'));" onkeyup="this.value=this.value.replace(/[^0-9]/g,'');"/></td>
								<td style="width:120px;text-align:left;">&nbsp;第${page.pageIndex}页，共${page.totalPage}页<input type="hidden" value="${page.pageIndex}" id="_pg_curr_index"/></td>
							</tr>
						</table>
					</td>
				</tr>
			</table>
		</div>
	</div>
</body>
</html>
